﻿module fitbit {
    'use strict';

    interface IActivityWidgetController {
    }

    interface IActivityWidgetScope extends ng.IScope {
        data: IFitbiActivityInfo;
        options: {};
        knobValue: number;
        knobOptions: {};
        SelectedView: string;
        vm: IActivityWidgetController;
    }

    class ActivityWidgetController implements IActivityWidgetController {

        static $inject = ['FitbitService', '$scope'];
        constructor(fitbitService: IFitbitService, private $scope: IActivityWidgetScope) {

            fitbitService.getActivity().then((data: IFitbiActivityInfo): void => {
                $scope.data = data;
            });

            $scope.options = fitbit.Helpers.GraphHelper.GetActivitySleepGraphOptions();

            $scope.vm = this;
            this.SetDefaults();
        }

        SetDefaults(): void {
            this.$scope.knobValue = 50;
            this.$scope.knobOptions = {
                width: 100,
                height: 100,
                readOnly: true,
                thickness: 0.3,
                fgColor: '#28beff',
                //angleArc: 180,
                //displayInput: true
            };
            this.$scope.SelectedView = "Steps";
        }

        onViewChange(selectedValue: string): void {
            this.$scope.SelectedView = selectedValue;
        }
    }

    export class ActivityDirective {
        constructor() {
            return this.CreateDirective();
        }

        private CreateDirective(): any {
            return {
                restrict: 'E',
                templateUrl: '/app/fitbit/widgets/activity/activityWidget.html',
                controller: ActivityWidgetController
            };
        }
    }

    angular.module('fitbitApp').directive("fitbitActivityWidget",() => new fitbit.ActivityDirective());
} 